package com.project.controller;

import com.project.bean.SpeakBean;
import com.project.bean.UserBean;
import com.project.service.ISpeakService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("speak")
public class SpeakController {
    @Autowired
    private ISpeakService service;

    @RequestMapping("add")
    public String add(int productId, String content, HttpServletRequest request){
        //从session中得到登录用户
        UserBean user = (UserBean) request.getSession().getAttribute("loginUser");

        SpeakBean speakBean = new SpeakBean(content,productId,user.getId());

        service.add(speakBean);
        return "ok";
    }
}
